home *** CD-ROM | disk | FTP | other *** search
- /*
- TimeUtils.c
-
- Demonstration of JDK Native methods.
-
- © 1997 by Michael J. Webb (mjw@codewell.com)
-
- */
-
- /* JavaH generated include. */
-
- #include "TimeUtils.h"
-
- /* MacOS Includes */
-
- #include <lowmem.h>
- #include <OSUtils.h>
-
- /* JDK Includes. */
-
- #include <javastring.h>
-
- /* ANSI Includes. */
-
- #include <stdio.h>
- #include <string.h>
-
- /** Native method to get the current time.
- */
- long TimeUtils_GetRealTime(struct HTimeUtils* this)
- {
- long realTime = 0;
- GetDateTime(((unsigned long*)(&realTime)));
- return realTime;
- }
-
- /** Native method to get the tick count.
- */
- long TimeUtils_GetRelativeTime(struct HTimeUtils* this)
- {
- SInt32 relTime = 0;
- relTime = LMGetTicks();
- return relTime;
- }
-
- /** Native method to convert a time to a string.
- */
- struct Hjava_lang_String* TimeUtils_GetTimeString(struct HTimeUtils* this, long someTime)
- {
- struct Hjava_lang_String* newString = NULL;
- DateTimeRec dateTime;
- char buffer[256];
-
- SecondsToDate(someTime, &dateTime);
-
- sprintf
- (
- buffer,
- "%d/%d/%d %d:%d:%d",
- dateTime.day,
- dateTime.month,
- dateTime.year,
- dateTime.hour,
- dateTime.minute,
- dateTime.second
- );
-
- newString = makeJavaString(buffer, strlen(buffer));
-
- return newString;
- }
-